<?php
//连接数据库
$link = new mysqli('localhost', 'root', '654321', 'shumei19', 3306);
if (!$link) {
    exit('数据库连接失败');
}
// 设置字符集
$link->set_charset('utf8');

$page = isset($_GET['p']) ? intval($_GET['p']) : 1;
if ($page <= 0) $page = 1;
$pageSize = 2;
$offsize = ($page - 1) * $pageSize;

// 准备sql语句
$sql = 'select * from users order by id desc limit '. $offsize .', ' . $pageSize;
// 执行sql语句，返回结果集
$result = $link->query($sql);
$data = [];
while($row = $result->fetch_assoc()) {
    $data[] = $row;
}
$link->close();
echo '<pre>';
print_r($data);
echo '</pre>';